import requests
from common.address import hostName, apiLogin
from common.vars import publicHeaders, publicUserName, publicPwd

def login_post(userName, password):
    urlLogin = hostName + apiLogin
    uploadsLogin = {
        "userName": userName,
        "password": password
    }
    return requests.post(url=urlLogin, headers=publicHeaders, json=uploadsLogin)


if __name__ == '__main__':
    resObj = login_post(userName=publicUserName, password=publicPwd)
    print(resObj.status_code)
    print(resObj.headers)
    print(resObj.text)
    print('-' * 100)
    resBodyJson = resObj.json()
    token = resBodyJson['data']['token']
    print(f'本次登录后获取到的token是：{token}')
